// pages/personal/deliveryAddress/deliveryAddress.js
import { addressList } from '../../../../config/config'
//获取应用实例
const app = getApp()
Page({

  /**
   * 页面的初始数据
   */
  data: {
    addressData: []
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    
  },
  // 收货地址查询
  addressList() {
    let that = this
    let params = {
    }
    console.log('params', params)
    app.reqFun.requestJson('POST',addressList,params,(res)=>{
      if(res.data.success === 1) {
        let addressData = res.data.data.records
        that.setData({
          addressData: addressData
        })
      }
    })
  },
  newAddress() {
    wx.navigateTo({
       url: '../../../../packagMy/pages/personal/newAddress/newAddress',
    })
  },
  // 跳转到编辑地址页面
  updateAddress(e) {
    console.log('e', e)
    // let id = e.currentTarget.dataset.item
    // let name = e.currentTarget.dataset.item.name
    // let phoneNumber = e.currentTarget.dataset.item.phoneNumber
    // let province = e.currentTarget.dataset.item.province
    // let city = e.currentTarget.dataset.item.city
    // let region = e.currentTarget.dataset.item.region
    // let street = e.currentTarget.dataset.item.street
    // let detailAddress = e.currentTarget.dataset.item.detailAddress 
    // let defaultStatus = e.currentTarget.dataset.item.defaultStatus 
    let option = e.currentTarget.dataset.item
    wx.navigateTo({
      url: '../../../../packagMy/pages/personal/newAddress/newAddress?option=' + JSON.stringify(option),
    })
  },
  toBack() {
    wx.navigateBack({
      delta: 1
    })
  },
  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {
    this.addressList()
  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})